@echo off
REM Celery启动脚本（Windows）
echo ========================================
echo 启动Celery Worker和Beat
echo ========================================
echo.

REM 检查Redis是否运行
echo 检查Redis连接...
python -c "import redis; r = redis.Redis(host='127.0.0.1', port=6379, db=0); r.ping(); print('Redis连接正常')" 2>nul
if errorlevel 1 (
    echo 错误: Redis未运行或无法连接
    echo 请先启动Redis服务
    pause
    exit /b 1
)

echo.
echo 启动Celery Worker...
start "Celery Worker" cmd /k "cd /d %~dp0.. && celery -A travel_plan worker --loglevel=info --pool=solo"

timeout /t 3 /nobreak >nul

echo.
echo 启动Celery Beat...
start "Celery Beat" cmd /k "cd /d %~dp0.. && celery -A travel_plan beat --loglevel=info"

echo.
echo ========================================
echo Celery已启动
echo Worker窗口和Beat窗口已打开
echo 按任意键关闭此窗口...
echo ========================================
pause >nul

